//
//  TRFansViewTableViewCell.m
//  WeiMiLan
//
//  Created by anan on 15/2/4.
//  Copyright (c) 2015年 Mac. All rights reserved.
//

#import "TRFansViewTableViewCell.h"

@implementation TRFansViewTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)fllowAction{
    int followId = [self.info ql_intForKey:@"USER_ID"];
    if (followId==0) {
        NSDictionary *dic = self.info[@"USER_INFO"];
        followId = [dic ql_intForKey:@"ID"];
    }
    
    NSDictionary *userInfo = [[QLUserManager shareInstance] getLastUserInfoFromNative];
    BOOL b = [[QLFollowManager shareInstance] isFollowWithUserId:followId myUserId:[userInfo ql_intForKey:@"ID"]];
    if (b) {
        [[QLFollowManager shareInstance] deleteFollowWithUserId:followId myUserId:[userInfo ql_intForKey:@"ID"] callback:^(BOOL isCache, id data) {
            self.info = _info;
            [[NSNotificationCenter defaultCenter]postNotificationName:@"kRefreshFollow" object:nil];
        }];
    }else{
        [[QLFollowManager shareInstance] addFollowWithUserId:followId myUserId:[userInfo ql_intForKey:@"ID"] callback:^(BOOL isCache, id data) {
            self.info = _info;
            [[NSNotificationCenter defaultCenter]postNotificationName:@"kRefreshFollow" object:nil];
        }];
    }

}
- (void)setInfo:(NSDictionary *)info
{
    _info = info;
    self.labelName.text = info[@"NAME"];
    self.imageViewIcon.layer.masksToBounds = YES;
    self.imageViewIcon.layer.cornerRadius = 17; //设置图片圆角的尺度
    [self.imageViewIcon setImageWithURL:[NSURL URLWithString:info[@"HEAD_PIC_URL"]] placeholderImage:[UIImage imageNamed:@"nodata_public"]];
    
    [self.fllowBtn addTarget:self action:@selector(fllowAction) forControlEvents:UIControlEventTouchUpInside];
}

@end
